package org.tulkas.ext;

import java.util.LinkedHashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * @author <a href="mailto:tulkas.web@gmail.com">Tulkas</a>
 *
 */
@Controller
public class ExtensionController {
	@Autowired
	private ExtensionManager extManager;

	@RequestMapping(value = "/extensionPoints", method = RequestMethod.GET)
	public String getAllExtensionPoints(Map<String, Object> model) {
		String[] ids = extManager.getAllExtensionPointIds();
		Map<String, String> points = new LinkedHashMap<String, String>();
		for (String id : ids) {
			IExtensionPoint point = extManager.getExtensionPoint(id);
			if (point != null) {
				points.put(id, point.getDescription());
			}
		}
		model.put("extensionPoints", points);
		return "extensionPoints";
	}
	
	
}
